<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../../common/taglib.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <%@include file="../../common/common-css.jsp" %>
    <%@include file="../../common/init.jsp" %>
  <script type="text/javascript">
  function allocation(){
       $.ajax({
      		async:false, //请勿改成异步，下面有些程序依赖此请数据
      		type : "POST",
      		data:{userId:"${user.userId}",roleId:$('input[name="roleId"]:checked').val()},
      		url: "${pageContext.servletContext.contextPath }/background/user/allocation.html",
      		dataType:'json',
      		success: function(json){
      			if(json == "1000"){
      			window.dialogArguments.location.reload();
		          alert("分配成功！！");
		          window.close();
              	}else if(json == "1001"){
              		alert("分配失败！！");
                };
       		}
      	});
      }
  </script>
  
  </head>
  
  <body>
		<div class="right" >
        	<div class="volume">
            	<img src="${pageContext.servletContext.contextPath }/images/toleft.png" style="margin:23px 0 0 2px;_margin:23px 0 0 0px;" />
            </div>
        	<div class="rightcon ">
            	<div class="title">
                	您当前的位置：首页 > 用户管理 > 分配角色
                </div>
                <table border="0" cellpadding="0" cellspacing="0" class="table1">
                	<tr>
                    	<td class="odd">用户名：
                        </td>
                        <td class="even">${user.userName}
                        </td>
                        <td class="odd">所属角色：
                        </td>
                        <td class="even"><c:if test="${empty user.roleName}">
						<font color="red">没有分配角色</font>
						</c:if>
						<c:if test="${not empty user.roleName}">
						<font color="blue">${user.roleName}</font>
						</c:if>
                        </td>
                    </tr>
                </table>
                 <table border="0" cellpadding="0" cellspacing="0" class="table2">
                 	<tr class="title">
                 		<td width="5%" align="center">
                        	
                        </td>
                        <td width="20%" align="center">
                        	角色名
                        </td>
                         <td width="10%" align="center">
                        	是否禁用
                        </td>
                        <td  width="10%" align="center">
                        	描述
                        </td>
                    </tr>
                   <c:forEach var="role" items="${roles}">
                    <tr class="odd">
                    <td height="20" >
		              <input type="radio" name="roleId" value="${role.id}" />
		            </td>
                        <td align="center">
                        	${role.name}
                         <td align="center">
                        	<c:if test="${role.enable eq '0'}">
				            <font color="red">禁用</font>
				            </c:if>
				            <c:if test="${role.enable eq '1'}">
				            <font color="blue">正常</font>
				            </c:if>
                        </td>
                        <td align="center">
                        	${role.description}
                        </td>
                    </tr>
                    </c:forEach>
                    <tr><td align="center" colspan="4">
                               <a href="#" onclick="allocation();"><img src="${pageContext.servletContext.contextPath }/images/baocun.png" width="101" height="46"/></a>
							    <a href="#" onclick="javascript:window.close();" ><img src="${pageContext.servletContext.contextPath }/images/fanhui.png" width="101" height="46"></a>
                    </td>
                    </tr>
                 </table>
                
            </div><!--rightcon-->
        </div>     
  </body>
</html>
